$(function(){
	$('.wrapper-manage').contextmenu({
		target : "#context-menu",
		onItem : function(context, e) {
			var expr = $(e.target).text().trim(); 
		},
		before: function (e) {
			e.preventDefault();
			if (!$(e.target).parent().hasClass('selected'))
				$(e.target).parent().click();
        }
	});
	$('.wrapper-manage').on('contextmenu', function(e) {
		e.preventDefault();
		if ($('#documentNameSelect').val() === ""){
			$('.default-context').removeClass('hidden');
			$('.table-context').addClass('hidden');
			$('.special-context').addClass('hidden');
		}
		else{
			$('.default-context').addClass('hidden');
			$('.table-context').removeClass('hidden');
			$('.special-context').addClass('hidden');
		}
		$('#dataTableManagement tr').each(function() {
		    if ($(this).hasClass('selected')){
		    	var cell = $(this)[0].getElementsByTagName('td')[0];
				if(cell.innerHTML.includes("Share_Folder.png")){
					$('.special-context').removeClass('hidden');
				}
		    }    
		});
		
	});
	$('#context-menu').on('show.bs.context', function(e) {
		console.log('before show event');
	});
	
	$('#context-menu').on('shown.bs.context', function(e) {
		console.log('after show event');
	});
	
	$('#context-menu').on('hide.bs.context', function(e) {
		console.log('before hide event');
	});
	
	$('#context-menu').on('hidden.bs.context', function(e) {
		console.log('after hide event');
	});
});